package com.psychologyCommunity.Community.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class AlphaAspect {
    @Pointcut("execution(* com.psychologyCommunity.Community.service.*.*(..))")
    public void pointCut(){

    }
    @Before("pointCut()")
    public void before(){
        System.out.println("before");

    }
    @After("pointCut()")
    public void after(){
        System.out.println("after");
    }

    @AfterReturning("pointCut()")
    public void afterReturning(){
        System.out.println("afterReturning");
    }
    @AfterThrowing("pointCut()")
    public void afterThrowing(){
        System.out.println("afterThrowing");
    }

    @Around("pointCut()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable{
        System.out.println("可以在调用组件之前写一段代码实现 逻辑！！！");
      Object obj=joinPoint.proceed();//织入的部位joinPoint 调用我们要处理的目标组件的方法
        System.out.println("可以在调用组件之后写一段代码实现 逻辑！！！");
        return obj;
    }
}
